package com.joy.demo;


import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

@ControllerAdvice
public class RestHandlerController{
    @ExceptionHandler(NullPointerException.class)
    @ResponseBody
    public Map<String, Object> resultError() {
        Map<String,Object> result = new HashMap<>();
        result.put("result_code",500);
        result.put("result_message","服务器错误");
        return result;
    }


}
